package com.daiyang.lottery.dao.mapper;

import com.daiyang.lottery.dao.dataobject.ActivityDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity(activity_name, description, status)" +
            " values(#{activityName}, #{description}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(ActivityDO activityDO);
    @Select( "select count(1) from activity")
    int count();

    /**
     * 翻页查询
     *
     */
    @Select("select * from activity order by id desc limit #{offset}, #{pageSize}")
    List<ActivityDO> queryActivitiesByPage(@Param("offset") Integer offset,
                                           @Param("pageSize") Integer pageSize);

    /**
     * 根据id查询
     *
     */
    @Select("select * from activity where id = #{activityId}")
    ActivityDO selectById(@Param("activityId") Long activityId);


    @Update("update activity set status = #{status} where id = #{activityId}")
    void updateActivityStatus(@Param("activityId")Long activityId, @Param("status")String name);
}
